<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工地项目列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>项目名称：</p> <input type="text" name="projectName"/>
                        </li>
                        <li>
                            <p>建设单位：</p> <input type="text" name="projectOwner"/>
                        </li>
                        <li>
                            <p>施工单位：</p> <input type="text" name="projectContractor"/>
                        </li>
                        <li>
                            <p>地址：</p> <input type="text" name="address"/>
                        </li>
                        <li><a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm"
                               onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()"
               shiro:hasPermission="process:project:add"> <i
                    class="fa fa-plus"></i> 添加
            </a> <a class="btn btn-warning" onclick="$.table.exportExcel()"
                    shiro:hasPermission="process:project:export"> <i
                class="fa fa-download"></i> 导出
        </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('process:project:edit')}]];
    var removeFlag = [[${@permission.hasPermi('process:project:remove')}]];
    var currentUser = [[${currentUser}]];
    var prefix = ctx + "process/project";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            detailUrl: prefix + "/projectDetails/{id}",
            modalName: "工地项目",
            columns: [{
                checkbox: true
            },
                {
                    field: 'projectId',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'projectOwner',
                    title: '建设单位'
                },
                {
                    field: 'projectContractor',
                    title: '施工单位'
                },
                {
                    field: 'contractCode',
                    title: '合同编号'
                },
                {
                    field: 'provinceid',
                    title: '归属省份',
                    visible: false
                },
                {
                    field: 'cityid',
                    title: '归属城市',
                    visible: false
                },
                {
                    field: 'areaid',
                    title: '归属区域',
                    visible: false
                },
                {
                    field: 'address',
                    title: '地址'
                },
                {
                    field: 'zfMan',
                    title: '执法管理人员',
                    visible: false
                },
                {
                    field: 'complaintsHotline',
                    title: '投诉热线',
                    visible: false
                },
                {
                    field: 'status',
                    title: '项目状态'
                },
                {
                    field: 'projectCode',
                    title: '项目编号'
                },
                {
                    field: 'remark',
                    title: '备注'
                }, {
                    field: 'createBy',
                    title: '创建账号'
                }, {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="fileForm(\'' + row.projectId + '\',\'' + row.createBy + '\')"><i class="fa fa-list-ul"></i>附件清单</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.projectId + '\')"><i class="fa fa-list-ul"></i>详情</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editForm(\'' + row.projectId + '\',\'' + row.createBy + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="removeForm(\'' + row.projectId + '\',\'' + row.createBy + '\')"><i class="fa fa-remove"></i> 删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function fileForm(id, createBy) {
        var url = prefix + '/upfiles/' + id;
        $.modal.openTab("附件清单", url);
    }

    function editForm(id, createBy) {
        $.operate.edit(id);
    }

    function detail(id) {
        $.operate.detail(id, 800, ($(window).height() - 10));
    }

    function removeForm(id, createBy) {
        $.operate.remove(id);
    }
</script>
</body>
</html>